package cn.forkway.learn.jdbcTry;

import java.sql.*;

/**
 * @program: java-learn-jdbc
 * @className: demo01.java
 * @author: River Ray
 * @description: JDBC第一次尝试初始化数据库
 * @createTime 2021年10月06日 11:10:00
 */
public class demo01 {
   public static void main(String[] args) {
      Connection conn = null;
      Statement stmt = null;
      ResultSet rs = null;

      try {
         //通过反射的方式去引如驱动类
         // 驱动类上面有一个静态代码块帮我们完成了驱动的注册
         Class.forName("com.mysql.cj.jdbc.Driver");
         String URL = "jdbc:mysql://localhost:3306/jdbctest";
         String USER = "root";
         String PWD = "250032";
         conn = DriverManager.getConnection(URL, USER, PWD);
         stmt = conn.createStatement();
         System.out.println("login in success !!!");
      } catch (ClassNotFoundException | SQLException e) {
         e.printStackTrace();
      }
   }
}
